package com.adam.management.controller.student.controller;


import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.adam.management.controller.student.service.StudentService;
import com.adam.management.controller.student.service.impl.StudentServiceImpl;
import com.adam.management.excel.ExcelUtils;
import com.adam.management.excel.MutiThreadRead;
import com.alibaba.fastjson.JSON;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.*;

@Controller
@RequestMapping(value = "/student")
public class StudentController {

    private static Logger logger = LoggerFactory.getLogger("StudentController");

    @Autowired
    StudentServiceImpl studentService;

    @RequestMapping("/list")
    public String studentList(){
        return "student/list";
    }

    @RequestMapping("/add")
    public String studentAdd(){
        return "/student/add";
    }

    @RequestMapping("/edit")
    public String studentEdit(){
        return "/student/edit";
    }

    @RequestMapping("/delete")
    public String studentDelete(){
        return "/student/delete";
    }

    /**
     * 导入店员信息
     * @author
     * @param file excel 文件
     * @return
     * @date 2019/12/26 13:16
     */
    @RequestMapping(value = "/import",method = RequestMethod.POST)
    @ResponseBody
    public String importStudent(@RequestParam("file") MultipartFile file) throws Exception {

        if (file.isEmpty()) {
            if (file.isEmpty()) {
                throw new Exception("上传文件不能为空");
            }
        }

        //调用多线程读取Excel的方法
        MutiThreadRead mutiThreadRead = new MutiThreadRead();
        mutiThreadRead.readExcel(file);
        return null;
    }

}
